'''
作业
'''
# 1.
sum1 = 0
for x in range(1, 101):
    sum1 += x
avg1 = sum1 / 100
print('和：{}，平均值：{}'.format(sum1, avg1))
x = 0
sum2 = 0
while 1:
    x += 1
    sum2 += x
    if x == 100:
        break
avg2 = sum2 / x
print('和：{}，平均值：{}'.format(sum2, avg2))

# 2.
sum3 = 0
for x in range(1, 101):
    if x % 3 == 0:
        sum3 += x
print('和：', sum3)

x = 1
sum4 = 0
while 1:
    x += 1
    if x % 3 == 0:
        sum4 += x
    elif x == 100:
        break
print('和：', sum4)

# 3.
sum5 = 0
for x in range(1, 101):
    if x % 7 != 0:
        sum5 += x
print('sum5和：', sum5)

x = 0
sum6 = 0
while 1:
    x += 1
    if x == 101:
        break
    elif x % 7 != 0:
        sum6 += x
print('sum6和：', sum6)

# 稍微困难
# 4.
# a, b = 1, 1
# n = int(input('请输入大于0的数：'))
# if n == 1:
#     print('斐波那契数列列中第1个数的值:', a)
# elif n == 2:
#     print('斐波那契数列列中第2个数的值:', a, b)
# else:
#     for i in range(n - 1):
#         a, b = b, a + b
#         print(a, end=' ')

# 提高
# 1.
age = int(input('请输入年龄：'))
if age <= 0 or age >= 150:
    print('年龄不合法')
elif age <= 8:
    print('儿童')
elif age <= 16:
    print('未年人')
elif age <= 35:
    print('青壮年')
elif age <= 50:
    print('中年')
else:
    print('老年')

# 2.
x = 1
for i in range(1,6):
    x *= i
print(x)
# 3.
x = 1
sum1 = 0
for i in range(1,21):
    x *= i
    sum1 += x
print(sum1)
# 4.
x = 1
sum2 = 0
for i in range(1,21):
    x *= i
    sum2 += 1/x
print(sum2)
# 5.
sum3 = 0
while 1:
    x = int(input('请输入大于0的数:'))
    if x == 0:
        break
    elif x > 0:
        sum3 += x
    else:
        print('请输入大于0的数')
